//
//  KLDealRecordTableViewCell.m
//  KunLun
//
//  Created by Mac on 2017/11/28.
//  Copyright © 2017年 stoneobs@icloud.com. All rights reserved.
//

#import "KLDealRecordTableViewCell.h"
@interface KLDealRecordTableViewCell()
@property(nonatomic, strong) STLabel                     *timeLable;
@property(nonatomic, strong) STLabel                     *desLable;
@property(nonatomic, strong) STLabel                      *idLable;
@end
@implementation KLDealRecordTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self configSubView];
    }
    return self;
}
+ (CGFloat)cellHeight{
    return 60;
}
#pragma mark --subView
- (void)configSubView{

    self.idLable  = [[STLabel alloc] initWithFrame:CGRectMake(0, 0, 100, 20)
                                              text:@"ID号:123456"
                                                textColor:KL_secendTextColor
                                                     font:13
                                              isSizetoFit:NO
                                            textAlignment:NSTextAlignmentRight];
    [NSString lableAutoAdjustWitdhWithLabel:self.idLable];
    self.idLable.right = UIScreenWidth - 10;
    self.idLable.centerY = [KLDealRecordTableViewCell cellHeight] / 2;
    //[self addSubview:self.idLable];
    
    self.timeLable = [[STLabel alloc] initWithFrame:CGRectMake(10, 10, 200, 16)
                                                     text:@"2017年11月28日14:59:46"
                                                textColor:KL_firstTextColor
                                                     font:15
                                              isSizetoFit:NO
                                            textAlignment:NSTextAlignmentLeft];
    [self addSubview:self.timeLable];
    
    self.desLable = [[STLabel alloc] initWithFrame:CGRectMake(10, self.timeLable.bottom  +10, 300, 16)
                                              text:@"收入:70 支出: -463"
                                          textColor:KL_redColor
                                               font:15
                                        isSizetoFit:NO
                                      textAlignment:NSTextAlignmentLeft];
//    NSAttributedString * text = [self.desLable.text st_convertAttributeStringWithKeyWords:@[@"收入:",@"支出:"]
//                                                                               attributes:@[@{NSForegroundColorAttributeName:KL_secendTextColor},@{NSForegroundColorAttributeName:KL_secendTextColor}]];
//    self.desLable.attributedText = text;
    [self addSubview:self.desLable];
    
}
- (void)setModel:(KLRecordModel *)model{
    _model = model;
    //status 1 + 2 -
    if (model.status.integerValue == 1) {
        self.desLable.text = [NSString stringWithFormat:@"收入:+%@元",model.money.description];
        self.desLable.textColor = KL_redColor;
    }else{
        self.desLable.text = [NSString stringWithFormat:@"支出:-%@元",model.money.description];
        self.desLable.textColor = FlatMint;
    }
    
    NSDate  * date = [NSDate dateWithTimeIntervalSince1970:model.created_at.integerValue].st_localDate;
    
    self.timeLable.text = date.st_yyyyMMddhhmmssWithDate;
}
@end
